package com.kuang.springcloud.controller;


import com.kuang.springcloud.entities.CommonResult;
import com.kuang.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@Slf4j
public class OrderController
{

    @Autowired
    private RestTemplate restTemplate;
    //http://localhost:8001/payment/get/1
    //public static final String URL = "http://localhost:8001";
    public static final String URL = "http://cloud-payment-service";

    @GetMapping("/consumer/payment/create")
    public CommonResult create(Payment payment)
    {
      return  restTemplate.postForObject(URL+"/payment/create",payment,CommonResult.class);
    }
    @GetMapping("/consumer/payment/get/{id}")
    public CommonResult get(@PathVariable("id") long id)
    {
        return  restTemplate.getForObject(URL+"/payment/get/"+id,CommonResult.class);
    }
    @GetMapping("/consumer/payment/zk")
    public String paymentzk()
    {
        return restTemplate.getForObject(URL+"/payment/zk",String.class);
    }


}
